""" Input mode deferrer. """

import plotCourse, dragMap
from pygame.locals import *

from pgEngine.boat import Boat

class MainMode:
    def __init__(self, game, window):
        self.game = game
        self.window = window
        
        # Make sure we draw the highlight.
        self.window.map.addCallback(self.onDraw)
        self.reAdd = False
    
    def onEvent(self, event):
        game = self.game
        
        if event.type == QUIT:
            return True
        elif event.type == KEYDOWN and event.key == K_ESCAPE:
            return True
        
        if game.state == game.WAITING_MY_TURN:

            if event.type == MOUSEBUTTONDOWN:
                
                if self.window.rcTabs.collidepoint(event.pos) and event.button == 1:
                        # Check the tabs
                        for tab in self.window.tabs:
                            if tab[2].collidepoint(event.pos):
                                self.window.switchTab(tab)
                                break

                elif self.window.rcMap.collidepoint(event.pos):
                    if event.button == 4:
                        self.window.mappos.y += 4
                    elif event.button == 5:
                        self.window.mappos.y -= 4
                    elif event.button == 6:
                        self.window.mappos.x += 4
                    elif event.button == 7:
                        self.window.mappos.x -= 4

        else:
            
            pass


